use decision tree pattern to write subscribe.js