Changed code to use JavaScript OOP + cleaning..