minor changes to logic