Implemented the first problem