updated merge_defaults method for flexibility