Remved duplicated code.