Cleaned up console logs and variable scoping