This code is ass but it does a thing