Habitat selection and territoriality