new solution with try adn catch