fixed and optimized