Added empty checks for H and W