reformat and add in remaining helper functions for lexer