refactored a lil bit, and some style