move commonly used functions into a separate module