refactored a lil bit