not sure why I did this in master but oh well, finally added cleanup function