Added state updater function