updating and optimizing code for tablet and mobile portrait