Too much code posted improperly (hard to read/understand). Please read this topic to learn how to post code correctly and other useful tips for newcomers.

You are repeating many calculations and...