Rewritten some methodes of the js and clean coding