merge @richard 's modification(GitHub #50 )