some imporovements and R interface function