refactored some logic into cache_control