refactored some more code -