cleaning up a bit of logic