Updated key logic