finalized working api