improved logic for flag code in fl.c