Added main feature detection code