added mesh
some refactoring