utilised the 3d dimension and cleaned vertex code