implemented both the cases