This is ugly so someone please tell me a better way :)