moved utility function