Took way too long but is now working