use explicit unsigned type in max operation