generic code to util