fixed invalid handle error