cleaned code duplication