complete refactoring based on PineJS v0.2.0