fixed Issue #29 and added logging to separate SQL