better api handling