Move generic functions to utils