working on flag code, and reformatted