working version of the program