Added While loop
Added functions for validating operaor and refactored code