Added before and after switch support