Converted database queries to prepared statements