added stored proc to make running more robust