Fix bug when switching between fields