completes logic for first part of puzzle solution