replace broken attempt by a partial solution to #165