Fix bug where the delegate was called twice