Better api loading logic