ugly but it works!