fixed a bug in searching and changed some args reading