polishing and corner case correctness