reducing doubled code