Optimized the code alot!