changed a few lines to make it easier to read