moving variables and method calls to body and fixed rendering issue