Updated normalize function for zero vector handling