ENH : improved efficiency

as suggested by Li Li