fixing logic mistake