some refactoring and switched to json encoded config file