create endings dictionary as intermediate step