Implementing lab5.