fixed a timing issue that prevented the directive from working