Updated detection script