ugly, but working