Improved code, adding documentations