fixed bugs
update to error handling