refactor for rmi and persistance