added calc rem function