formatting and refactoring changes
changed all member vars to locals for better encapsulation