moved chunk into if statement