added null check on dispose