code duplication;needs refactored