fixed and refactored some things