Beginning to abstract and simplify the 3d logic