fixing up some logic issues
Merge remote-tracking branch 'origin/master'