Made the javascript counter function