fix program logic