board logic rewritten in coffescript