fixed to avoid "template recursion depth exceeded" error.