more fixes to logic