adding previous code from 6.S194