simplified algoritm for first task