add date_inserted method and reorganize things slightly