added error handling to pies