Moved logic away from some ui stuff