apply used instead of 2 state vars