first implementation of the second function