Refine code better organized