cleaned things up, organized it into a class