small fixes to logic