fixed the issue of sql statement being empty