added initial code based on the source publish on google code