added some more error checking
-Fixed bug in ram where it was using the wrong variable name