ugly but working.