Remove unnecessary loops for finding keys.