added @miisterpatate modifications