- moved one line into an if loop to prevent it to be carried out multiple times.