add previous key check