Fixed expiry bug and added logic to only check non expired when configured