Fix duplicate code