stupid and ugly but it works I hope