clean the code and use the factory to get some objects