refactored and cleaned up code, updated records