fixed problem with KEY being set incorrectly