added Brian's code