added detectOne function