code optimized, code for binding events changed, init added