first implementation of code