fix some logic error and add search bar