conditionally attach callbacks