refactored
almost everything