Added detection function