nit: have you considered turning this function into a constexpr function?