optimised code snippet