Code duplication fix?