js refactoring, use of snap.svg