System.arraycopy was used instead of manually array copying