cleanup and implementing protocol