First version of application. Experienced problems with the if loop