added key expiration checking