Correcting the logic