delete unused code
formatting, also fixed logic bug