fix logic mistakes