some streamlining of the code