TODO: recursive record and function