Cleaned up expect code