Added source code for version 4