Fixed minor error and did refactoring