Function fixed for correct template