moved utility code