some cleanup... an attempt at a generic map fn