refact x, add auto-checking