Avoid using copyOfRange