Cleaned up the function, one less variable declaration