Optimized code a little