Working version of the program