rewrite to remove jQuery dependency