Re-factored custom viewport fix