Slightly cleaned the code