updated structure and added in a SQL injection check