refactoring
fixed sqls