implements switch method to perform operations