Settings

capsuled settings functionality to functions and clean up code