Modified some parts of the code to simplify it