copy function to trait to make it a class