moved condition outwards