refactor with methods (properly this time)