fixing indentation and cleaning up code