some more structuring.  added map function to handle results more nicely.