fixing logic