correcting logic