added a sweep function