wrapped if statement around observer method
Formatted code