Moving to higher dimensional problem. May rewrite the follow code to be more object oriented