Changed some syntax name. Changed some function name. Added some error handling functions