code refactored for case and new endpoints added for case