refactored to use private variables when not needed to be public