improvements to logic