add cast to intmax_t to avoid warning