changed api to factory model