Some useful functions I wrote