Found a bug when fiddling with this and fixed it and removed some redundant code to keep it under the size limit.