cleaning up prepare code