moving to stored procedures [WIP]