Add factory to delete duplicate code