Fixed all bugs.
Added check_input flag