add attachRating function.