refactored some stuff