move detect call into next tick