split out cubifier algorithm