fix detection and add comments