changed to arraycopy
formatting