Fixing bug with expiration time calculation