trying to make this not look like spaghetti code