work in progress
helper functions and reformat