Moved code to rest class.