Working. Added error checking and fixed initialization
Tired of dev branch