Code style changes

Use where expressions instead of let expressions for local function
definitions if it enhances readability