fix bugs in backward, merge backward and forward, TODO: backward phase stops at middle layer, solve this issue