fix & refactoring of logic operators in template