Two errors corrected and refactoring done.