updated layout algorithm to do divides