Changed statement to prepared statement
fixed bug
Updated reference generator