Fix bug in code discovering unit used