added filewriting and edited layout