Added indentation and fixed caching