Fix logic bug in setting expiration.