Refactored a lil bit.