modify bug and improve function