added stuff stolen from Yuji