Changing states with pure functions