Refactored to eliminate 30 lines of code!