moved logic from case statement into methods