changed to stored procedures