refactos for clearer logic