optimized code. and it still gives correct information