Initial code from paper