optimized code a little a bit