[#4] Refactor: move logic functions to logic.py