Cleaned up a for/if loop