Finished the general function with examples :)