This set of functions is a lot cleaner now :)