fixed some bugs and formatting