added hits collection and cleanup function