Replaced some complex code with simple code