implement and document detection algorithm and usage