refactored and cleaned up some methods