use swap! to avoid loosing cache updates