Wrote recursive print function