some really dumb code in there - fixed