fixed paging problem and better API error handling