fixed #19

reworked code to remove possibility of history looping causing double
requests, resolved NaNs as a side effect.