Updated the logic & added new modes.