Fix errors. Tested code all working