Final flag assignment

fully functional