used more portable function definition