formatted, moved logic