First working version of search