finish calculating u matrix