Utility functions, extensions and helper methods