work on define and replace function