refactored some sh***