ugly as hell, but minimal functionality