getting cannot call method replace of undefined :(