upgraded to stored proc