minor bug fix on discovering habtm models