Ugh... this code is messed up...