Fixed formating and cleaned up code