move utility function up