Debug in locate function