Reformatted the code and removed comments for code which function is obvious