new version of program fulfilling the test conditions without introduced classes