Small improvement suggested by Andrew Or