Some useful functions as a library