with some modification in code style and documentation