logic error with numkeys being set