An Efficient Algorithm for Unit Propagation