replacement for #21. fixed #26