add onclick event and make it run intermittently