moved sweep logic in to a method called sweep()