Changed calculations so window can be resized easily