remove code duplication in src/Model.java