Move generic functions to utils module