add working unrefactored code.