Cleaned up javascript