few optimizations
md