Added logic to control empty input fields