debug the exists check.
Add some documentation