refactoring halfaway