modified code to use IOHandler functions instead of own ones