Fixed tag splitting code as a two-step solution and tidied up indenting