Refactored LU code