updated code around view contains subview