Added algorithm and basic alpha code

Needs to be optimized and code needs to be cleaned up.