Breaks added and some refactoring done