optimize post-command hook