Remove try catch in on method

An if statement is faster and more succinct.
Mark painter context (ctx) as private