removed sleep in sw; updated sql query