Refactored canvas js and models