implemented check_session function