Fix spacing and adding more error checking