Cleaned up and commented latest implementation