Separated into two different functions - should fix the issues.