used object oriented javascript and avoided global variables
make code more oo