Replaced code by getAbsoluteUrl removing repeated lines