made changes as per code review feedback: add variable, fix indentation etc