calculates moves