Fix bug in unit conversion