RESTWS-368: refactored code