increased speed and optimized a bit