added condition to check max $count