replaced UINT16_MAX with std::numeric_limits<uint16_t>::max