fixing some mistakes, really should test my code before commiting...