this addresses #271, probably needs polishing