work on history sql, not sure if ok. needs testing