Changed to support both landscape and portrait