refactored some stuffs