refactored/cleaned code