modified Greg's code about add Steven's code