almost working code, with some parts commented out