finally solved, revisit for understanding