add ended event listener instead of using .onended