cleanup

separated some of the functions out