fixed bug with input position calculation