re #82 refractor code