added check to ensure count/offset is greater than 0