some ecode refactoring