moved generic functions to util file
fixed merge