#313 refactoring