Alternative solution using union