changed logic of conditional statement and removed debugging prints