Refactored the taskSelector code and test case
Completed the refactoring of the taskSelector and introduced it inside the run() method