Switch button implemented for handling events
Added comments