added implementation of first problem