first implementation with comments and scaladocs