formated code and fixed some more errors