new utility functions, with test cases