Working search function plus some game logic