Merged existing code from http://www.accuratuslabs.com/test