Reformatted and refactored