updated code duplication