This code is simple but very useful, so why not to share?