add error catching and session