use ssize_t instead of int for min/max