fixed up crap code