Refactor to group code better