Added lagpad function.