new changes

- updated detach (it waits for last query)
- improvement retrieve data