very ugly but works