useful function definition