I'm not sure whether this is clever or not, because I don't really know what the state bits mean, so I decided to keep them.