corrected by stupid closure (lines 105-109) credit sokolov.