can work now. need to be further optimization