refactor code for searching soulmate