Added null check in setScale