moving code around and trying to fix bugs