Merging both functions into the same form, using rebuild function after the filtering process