removed write2file function