Simplify stored procedure