refactored sequential execution of copyif/copyn to allow for backward compatibility pre c++11