Implemented all features from lecture 6