added protection, added template range