removed variable usage by reference
fixed sql statement error