Refactor logic
Refactor logic 2
Refactor logic 3