Refactored to have database variables stored in class.