a more swift-like attempt