Ok, WAY less hacky solution. Duh