Refactored a lil bit