work on the logic