optimization & fix