Cleaned up functions.js