addressing errors in tokenify and mode_func