Added implementation of part of ex. 3