Used elsif instead of nested ifs