Extract to_dict method to own file