refactored to method;
initialized some vars;