Fix the bugs in implementation of momentum