Reformatted code and fixed minor spelling mistake