cleaning up logical flow