fixing logic for mode