refactored several local variables into fields and changed methods calls
appropriately