add tracking feature and fix some bugs