added alternative method for ex 3