modify utility function & add test cases