Modified to prevent SQL injection attacks