Added better position handling in template