solution exceeds 3000bytes, so trimmed out the fat