Added error checks to prevent displayed warnings