edited to be generic