reformat code and implement the __clone method