Get rid of this incrediby messy code