Replaced byte[] with ByteArrayOutputStream