unit tested, updated formatting for cleaner look