Outsource createMesh as function