fix type inference issue with auto + improve coding style