Added replace type function