refactored interactions code