fixed duplication code