did some refactoring and simplified things. also added test.json for test