backend algorithm revised