use dom instead of jquery, refactor events