added functions using where, let, and recursion