move header and use rLen variable