resolving issue with order of events