refactored local varilables