fixed run-time bugs