moved utility functions