better coding style in final version 3