fixed a crash reported by dimeptr in  Issue #1