switching logic for if in callback