useful functions and reformatting