lab2 end implementation