check for nested lists improved