Refactor the control flow pattern

Use callback  instead of eventListeners

  fits.readFile(file, function(err, data){…}