Fixes function, debug errors