still need to find a way to assign algorithm dynamically. Also need to fix the css. But first I think I want to read more about javascript design patterns.