added hashmap to attempt dynamic programming matrix write