Improve logic