added logic to automatically calculate the fetch count