Fix Error due to setting factory twice