fixed duplicate code