refactored controller using grape api group feature
added more resilient scenarios
refactored controller using helper method to remove duplicates