Same comment as ^. Try to dehydrate the code by declaring variables which would be reused in the queries. It will optimize the code a lot. If one day we would need to make a change in the parameters passed into those queries we would not need to change every single row but only 1 or 2 variables.