fixed a couple bugs that came from moving code around