fixed code duplication in server