Modified version of the code. Undefined reference has been fixed.