Rewrite the retrieveFromPath function to be more readable and error-safe