changed fileio to chained promises