fixed custom template logic