added 3 param condition for context drawImage