corrected and simplified definition logic to avoid deleting an expression that gets retained by a lambda