The ``$template`` variable created here is not used. I think you should remove this line.