changed iterative code to object oriented
added old stuff