Error in frappe call inside if-else statement

I have a select type field category and on change of that, I am triggering to if else, that if condition 1 is selected go to if segment and run that frappe call. If selecting second option, go to else segment and run that frappe call. For the first time, it is working correct. But my case:

Let there are 3 options in select field. User has to select 2nd option but by mistake he selects 1st. Here first conditions’s frappe call runs. But then he realizes he made mistake and then selects 2nd option. In that case frappe call is giving error. So is that any event or method that on each select-field change, my frappe call runs without any issue.

Thanks in Advance

Solved. Just used a common function in place of 3 frappe calls with dynamic filters/fields and voila, that worked