Fixed Small bug in template selector

The template selector could ignore the result of the selector function.