it's ugly but it works