utility functions and classes