Made javascript more object oriented