added checking for the selected fields