Solved flags problem