refactored and moved generic funcs/structs to util package