Bug in unit vector calculation