refactored
added cache
added condition for export