key logic