implemented copy() and fixed some lambda expression issues