cleaning up the logic.