style modification and cleaned up code