First commit, it works but have not tested it on all errors