Solution for first task