re-arranged tests for slight optimisation