Partial implementation of week7.