Minor bug fixed

bug fixed and optimised