fixed some compile and logical errors, whoops