optimised code

optimization code