optimize layout algorithm