fixing some bugs and indentation