Refactored afew things