Optimised the crappy code