ugly code but progress all the same