optimized the code even more