replaced some template int on helper functions with int function parameter