Implement #26 (to be fully tested)