Added some error-prevention