first implementation of solution