cleaned up code, fixed bug with config