debugged read in functions and decode flag