Use stored procedures instead of hard-coded queries