Refactor: Rearranged code