Improve list detection logic