try to optimise but some bug found