Refactored Canvas code to another JS file.