@Ghirigoro Thanks, that would speed things up. I remove rects i have merged from the array but your way would avoid the cost of removing.
@drewish thats great, i will check it out. I will be doing this task once in the setup function and then using the results else where in my app so being slow might not matter too much. Accurate is more important.