fixed script to enable and disable fields as necessary