added default mode value
code refactoring