more efficient impelementation of nan boxing