added errorhandling, but i think it's broken