Refactor after Ogail's code review