Refactored to used passed uri as api endpoint