trying to get code working from beginning to end