Some other ugly code connected to search