adding intial js code and linked to original author