Refactor fieldState plugin