changed constructor to pass by copy