moved logic into search bar directive