move function definition into class condition