some if statements added to store data in the correct table in my sql db