Made the function generic