adjusted exception handling to return correct formats