started rewrite and combined everything into file