almost done second variant
final solution