updated indetation and cleaned up code