Feature/separate logic from endpoint