Investigating storing state in function returns