Refactor code for duplicates checking to better location (listeners)