changed function to use more i/o