added clone method and the types are now handled correctly