removed nested cases and added new function for it