working program, need to add recursion