finished implementation for temporal pooling phase 2