got rid of a lot of duplicate code (im dumb)