MAIN LOGIC FIXED