handling historical data and automating record deletion