fixing if check in template for $error