improve sql. fix #49