Adapted for lab7