logic corrected