Fixed key searching algorithm again