improve code and upgrade to meet textiijs v0.3.0 api