ugly, but it works... will cleanup later.