Call update only on state change
Fix tabs and spaces