improved numBytes implementation