finished first implementation