EDIT: Fix unfactored code