Added pagination handling