Added the initial version of code, written by Jorge.