Refactored a dirty workaround