First pass at tail recursive solution