cleaner implementation of crash fix