replaced manual loop for copying byte array with System.arraycopy