added logic to look for keys