Fixed previous fix

last commit introduced a bunch of bugs