refactoring - introducing nextState() method