fixing up some logic issues