fix spacing and some logic errors