add select and fix some bug