refactored to allow calling different api urls