added m2m support