refactored out uint packing into a convenient function