fix problem with limit and joins