Broke code up into functions; fixed some issues with the scoring function