cleaned up and refactored a bit