Fixed missing sql queries