optimize crs function