changes to reduce size to respect max awidth and height