fixing bug in api connection