Completed layout alg