King David learned from his past