move commonly used functions to util