refactoring code and add parse json