Added error checks and word quoting