remove jquery; refactor code