fix to use size_type for ret value