Fixed add and edit queries