common code for backends