Refactored the code for feeding the Searching functionality of permutas.